﻿
#################################################
# 
#   数据库实体生成工具 (Database Generator) :
#   说明：PowerShell中执行
#
#   默认模板：【Windows】%UserProfile%\.nuget\packages\dotnet-ef\<版本号>\Templates\
#                  【Linux】~/.nuget/packages/dotnet-ef/<版本号>/Templates/
##################################################


# 指定模板: --context "/path/to/customtemplate.cshtml"
dotnet ef dbcontext scaffold "Server=127.0.0.1;Database=School;User=sa;Password=Pass1234;TrustServerCertificate=true"  `
Microsoft.EntityFrameworkCore.SqlServer `
-n School.Entities `
--no-onconfiguring `
--no-pluralize -f -v `
-c SchoolContext `
-o ./Entities

if ($LASTEXITCODE -eq 0) {
    Write-Host "====== 生成成功 ======"  -ForegroundColor Green -BackgroundColor Black
} else {
    Write-Host "====== 生成失败 ======"  -ForegroundColor Red -BackgroundColor Black
}
Write-Output ""
Read-Host -Prompt "按任意键结束 . . ."